package com.xiaolun.other;

import java.io.*;

public class Demo08 {
	public static void main(String[] args) {
		outputStreamWriterDemo();
	}

	private static void outputStreamWriterDemo() {
		String separator = File.separator;
		File file = new File("D:" + separator + "test" + separator + "test3.txt");
		if (file.exists()){
			FileOutputStream output = null;
			OutputStreamWriter out = null;
			try {
				output = new FileOutputStream(file); //字节流
				out = new OutputStreamWriter(output); //字节流转换为字符流
				out.write("nihao ---------------"); //可以直接输出字符串
				out.write("你好，世界---------------"); //方便处理中文
			} catch (Exception e) {
				e.printStackTrace();
			}finally {
				try {
					out.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
				try {
					output.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}
}
